<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 选择唯一一个子元素 */
      /*   .child:only-child {
            color: red;
        } */


        /*  */
        .child:only-of-type {
            color: blue;
        }
    </style>
</head>

<body>
    <div class="parent">
        <!-- <div class="child">child1</div> -->
        <div class="child">child2</div>
    </div>


    <div class="parent2">
        <div class="child">child1</div>
        <div class="child">child1</div>
        <div class="child">child1</div>
        <div class="child">child1</div>
    </div>
</body>

</html>